from jili.calc import calcor_base
from scipy.stats import siegelslopes
import numpy as np

# 计算ICU均线

class ICU(calcor_base):
    def __init__(self,ta_arg={}):
        self.out = ["icu_ma"]
        self.input = ["close"]
        self.parameters = {"timeperiod":10,"matype":10}
        super().__init__(ta_arg)
        self.batch=self.parameters["timeperiod"]
        self.isfirst=True
        self.m=round((self.batch - 1) / 2)
    def calc(self):
        srs= self.hisbars[self.input[0]]
        beta, mu = siegelslopes(srs, method='hierarchical')
        y = mu + beta * self.m
        return y
